import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/8 15:47
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[][] q = {{3,3,0}, {1,2,0}, {0,3,1}, {0,3,2}, {0,4,1}};
        solution.canMakePaliQueries("abcda", q);

    }
    public List<Boolean> canMakePaliQueries(String s, int[][] queries) {
        List<Boolean> result = new ArrayList<>();
        int cur = 0;
        int[] states = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            cur ^= (1 << (s.charAt(i) - 'a'));
            states[i] = cur;
        }
        for (int i = 0; i < queries.length; i++) {
            int ostate = queries[i][0] > 0 ? states[queries[i][0] - 1] : 0;
            int state = ostate ^ states[queries[i][1]];
            int cnt = 0;
            while (state != 0) {
                if ((state & 1) == 1) {
                    cnt++;
                }
                state >>= 1;
            }
            result.add(cnt / 2 <= queries[i][2]);
        }
        return result;
    }
}
